using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Linq;
namespace QuizNet
{
    public partial class frmMonHoc : DevComponents.DotNetBar.Office2007Form
    {
        public frmMonHoc()
        {
            InitializeComponent();
        }
        clsMonHoc clSub;
        private void frmMonHoc_Load(object sender, EventArgs e)
        {
            clSub = new clsMonHoc();
            loadDataGridView();   
        }
        private void loadDataGridView()
        {
            dgvMH.DataSource = clSub.layDSMonHoc();
        }
        private void btnthem_Click(object sender, EventArgs e)
        {
            MON_HOC mh = new MON_HOC();
            //mh.ma_mon_hoc = System.Guid.NewGuid();
            mh.ten_mon_hoc = txtTenMH.Text.Trim();
            clSub.themMonHoc(mh);
            loadDataGridView();
        }

        private void btnxoa_Click(object sender, EventArgs e)
        {
            if (dgvMH.SelectedRows.Count>0)
            {
                string mmh = dgvMH.SelectedRows[0].Cells[0].Value.ToString();
                clSub.xoaMonHoc(mmh);
                loadDataGridView();
            }
           
        }

        private void btnsua_Click(object sender, EventArgs e)
        {
            if (dgvMH.SelectedRows.Count > 0)
            {
                string mmh = dgvMH.SelectedRows[0].Cells[0].Value.ToString();
                clSub.suaMonHoc(mmh, txtTenMH.Text);
                loadDataGridView();
            }
        }
    }
}